'use strict';
module.exports = {
	/**
	 * 模拟并发测试
	 * @url template/test/pub/bathRun 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		let batchRunRes = await vk.pubfn.batchRun({
		  // 主执行函数
		  main: [
		    async () => {
					return uniCloud.callFunction({
						name:"router",
						data:{
							uni_id_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIwMDEiLCJyb2xlIjpbImFkbWluIl0sInBlcm1pc3Npb24iOltdLCJpYXQiOjE2NjI0Mzg4OTQsImV4cCI6MTY2MzA0MzY5NH0.Y4rTYzzMAkLK0ipshblCTa_v_3vhsik4UPgdjWVxWfA",
							$url: 'client/user.receiveCoupon',
							data: {
								coupon_id: "0a4ec1f96316b1c71e1e649e097e4e41"
							},
						}
					});
		    },
		    async () => {
		      return uniCloud.callFunction({
		      	name:"router",
		      	data:{
		      		uni_id_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIwMDMiLCJyb2xlIjpbXSwicGVybWlzc2lvbiI6W10sImlhdCI6MTY2MjQzODgxOCwiZXhwIjoxNjYzMDQzNjE4fQ.0GfDnM9V_Pah4E5fGF6MD205EEB4eXaGXLt_twq3vT0",
		      		$url: 'client/user.receiveCoupon',
		      		data: {
		      			coupon_id: "0a4ec1f96316b1c71e1e649e097e4e41"
		      		},
		      	}
		      });
		    }
		  ],
		  // 最大并发量，如果设置为1，则会按顺序执行
		  concurrency: 10
		});
		console.log("batchRunRes.stack",batchRunRes.stack)
		res.group = batchRunRes.stack;

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
